/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	AStoreQueryParamConverter.java
 * Created：		2016年9月5日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.common;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.spi.common.SSubjectWithDirection;

/**
 * @author wolv
 *
 */
public class ASubjectWithDirectionConverter implements Converter<SSubjectWithDirection, ASubjectWithDirection> {

	public static ASubjectWithDirectionConverter getInstance() {
		if (instance == null)
			instance = new ASubjectWithDirectionConverter();
		return instance;
	}

	private static ASubjectWithDirectionConverter instance;

	private ASubjectWithDirectionConverter() {
	}

	@Override
	public ASubjectWithDirection convert(SSubjectWithDirection source) {
		if (source == null)
			return null;

		ASubjectWithDirection target = new ASubjectWithDirection();
		target.setDirection(source.getDirection());
		target.setSubject(UCN.newInstance(source.getSubject()));

		return target;
	}

}
